import axios from "axios";
import { Message } from "element-ui";


const headers = {
	"Content-Type": "application/json",
	"Access-Control-Allow-Origin": "*"
};


// /api/web/workbench
// create an axios instance
// 请求地址设置
const service = axios.create({
	baseURL: 'http://110.40.214.107:8087',//process.env.VUE_APP_BASE_URL,
	timeout: 60000, // request timeout
	headers
});

service.interceptors.response.use(
	response => {
		const { code, msg } = response.data;
		if (code != 200) {
			Message({
				message: msg,
				type: "error",
				duration: 1000
			});
			return Promise.reject();
		}
		return response.data;
	},
	err => {
		Message({
			message: "服务器开小差啦~",
			type: "error",
			duration: 1000
		});
		return Promise.reject(err);
	}
);

export default service;
